// pages/studyinfo/studyinfo.js
var WxParse = require('../../wxParse/wxParse.js');
const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    sendId:null,
    mass: null,
    photourl:null,
    signurl:null
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    wx.showLoading({
      title: '加载学习内容'
    })
    wx.request({
      method: 'GET',
      url: app.globalData.serverPath + "api/bs-mass-centers/" + options.id,
      header: {
        'Authorization': app.globalData.token
      },
      success: function (res) {
        console.log("api/bs-mass-centers/", res)
        var tempmass = res.data;
        tempmass.month = tempmass.createDate.split("-")[0] + "/" + tempmass.createDate.split("-")[1];
        that.setData({ mass: tempmass });
        var articledesc = tempmass.des;
        WxParse.wxParse('articledesc', 'html', articledesc, that, 5);

        var articlecontent = tempmass.content;
        WxParse.wxParse('articlecontent', 'html', articlecontent, that, 5);


      },
      fail: function (error) {
        console.log("error", error);
      },
      complete: function () {
        wx.hideLoading();
      }

    });

    wx.request({
      method: 'GET',
      url: app.globalData.serverPath + "api/bs-mass-center-send-users/" + options.sid,
      header: {
        'Authorization': app.globalData.token
      },
      success:function(res){
        that.setData({
          massLineId:res.data.massLineId,
          photourl:res.data.headUrl,
          signurl:res.data.signUrlId
        });
        if (res.data.studyType==1){
          wx.request({
            method:'GET',
            url: app.globalData.serverPath + "api/bs-mass-line-pics/" + res.data.massLineId,
            header: {
              'Authorization': app.globalData.token
            },
            success:function(result){
              that.setData({
                massLinePic1: result.data.picOneId,
                massLinePic2: result.data.picTwoId,
                massLinePic3: result.data.picThreeId,
                massLinePic4: result.data.picFourId
              });
            }
          });
        }
      }
    })
  },

  showimage:function(e){
    var that=this;
    var imageurl=e.currentTarget.dataset.imageurl;
    wx.previewImage({
      current: imageurl,
      urls: [imageurl]
    })
  },


  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  }
})